package com.test.jpa.spring.service;

import com.test.jpa.spring.dao.PersonDao;
import com.test.jpa.spring.entities.Person;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author lzy
 * @version v1.0
 * Create DateTime: 2018/10/23 18:05
 */
@Service
public class PersonService {
    @Autowired
    private PersonDao personDao;

    @Transactional(propagation = Propagation.REQUIRED)
    public void savePersons(Person p1, Person p2) {
        personDao.save(p1);
        int i = 10 / 0;
        personDao.save(p2);
    }
}
